load("@rules_java//java:defs.bzl", "java_library")

package(
    default_applicable_licenses = ["//:license"],
    default_visibility = [
        "//parser:__pkg__",
        "//publish:__pkg__",
    ],
)

# keep sorted
PARSER_SOURCES = [
    "CelParserImpl.java",
    "ExpressionBalancer.java",
    "Parser.java",
]

# keep sorted
PARSER_BUILDER_SOURCES = [
    "CelParser.java",
    "CelParserBuilder.java",
    "CelParserLibrary.java",
]

# keep sorted
MACRO_SOURCES = [
    "CelMacro.java",
    "CelMacroExpander.java",
    "CelMacroExprFactory.java",
    "CelStandardMacro.java",
]

# keep sorted
UNPARSER_SOURCES = [
    "CelUnparser.java",
    "CelUnparserFactory.java",
    "CelUnparserImpl.java",
]

java_library(
    name = "parser_factory",
    srcs = ["CelParserFactory.java"],
    tags = [
    ],
    deps = [
        ":parser",
        "//common:options",
        "//parser:parser_builder",
    ],
)

java_library(
    name = "parser",
    srcs = PARSER_SOURCES,
    tags = [
    ],
    deps = [
        ":macro",
        ":operator",
        ":parser_builder",
        "//common:cel_ast",
        "//common:cel_source",
        "//common:compiler_common",
        "//common:options",
        "//common:source_location",
        "//common/annotations",
        "//common/ast",
        "//common/internal",
        "//common/internal:env_visitor",
        "//parser:cel_g4_visitors",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven//:com_google_guava_guava",
        "@maven//:org_antlr_antlr4_runtime",
    ],
)

java_library(
    name = "parser_builder",
    srcs = PARSER_BUILDER_SOURCES,
    tags = [
    ],
    deps = [
        ":macro",
        "//common:cel_source",
        "//common:compiler_common",
        "//common:options",
        "@maven//:com_google_errorprone_error_prone_annotations",
    ],
)

java_library(
    name = "macro",
    srcs = MACRO_SOURCES,
    tags = [
    ],
    deps = [
        ":operator",
        "//:auto_value",
        "//common:compiler_common",
        "//common:source_location",
        "//common/ast",
        "//common/ast:expr_factory",
        "@maven//:com_google_errorprone_error_prone_annotations",
        "@maven//:com_google_guava_guava",
    ],
)

java_library(
    name = "operator",
    srcs = ["Operator.java"],
    tags = [
    ],
    deps = [
        "//common/ast",
        "@maven//:com_google_guava_guava",
    ],
)

java_library(
    name = "unparser",
    srcs = UNPARSER_SOURCES,
    tags = [
    ],
    deps = [
        ":unparser_visitor",
        "//common:cel_ast",
        "//common:options",
    ],
)

java_library(
    name = "unparser_visitor",
    srcs = ["CelUnparserVisitor.java"],
    tags = [
    ],
    deps = [
        ":operator",
        "//common:cel_ast",
        "//common:cel_source",
        "//common/ast",
        "//common/ast:cel_expr_visitor",
        "//common/values:cel_byte_string",
        "@maven//:com_google_guava_guava",
        "@maven//:com_google_re2j_re2j",
    ],
)
